const commonUtil = require('../util/commonUtil');
const fileUtil = require('../util/fileUtil');

execute();

function execute() {
    let list = getTestExcelData();
    list.forEach(x => {
        let time = commonUtil.formatExcelDate(x.time, 'yyyy/MM/dd HH:mm:ss');
        console.log('time=[%s]', time);
    })

    fileUtil.writeToFile('../../data/testFile.txt', '测试内容1\n测试内容2');
}

function getTestExcelData() {
    //取出excel中的应付账款买卖方明细
    let excelData = commonUtil.getSheetByPathAndSheetName('../../data/testExcel.xlsx', 'Sheet1');
    //去掉标题
    excelData.splice(0, 1);
    //返回结果
    let result = [];
    let row = excelData.length;
    for (let i = 0; i < row; i++) {
        let excelItem = excelData[i];
        let item = {};
        if (excelItem == null || excelItem.length === 0) {
            continue;
        }
        item.bankId = excelItem[0];
        item.bankName = excelItem[1];
        item.price = excelItem[2];
        item.time = excelItem[3];
        result.push(item);
    }
    return result;
}